import Vue from 'vue'
export default {
  install () {
    Vue.directive('fofo', {
      inserted (el) {
        // el.querySelector('input').focus()
        let isFind = false

        if (el.nodeName === 'INPUT' || el.nodeName === 'TEXTAREA') {
          el.focus()
          isFind = true
        } else {
          const inp = el.querySelector('input')
          const ta = el.querySelector('textarea')
          if (inp && inp.nodeName === 'INPUT') {
            inp.focus()
            isFind = true
          }
          if (ta && ta.nodeName === 'TEXTAREA') {
            ta.focus()
            isFind = true
          }
        }
        if (isFind === false) {
          throw new Error('不要玩我')
        }
      }
    })
  }
}
